package com.notetool.dataprovider.flatfile;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.notetool.dataprovider.NoteDataValidator;

public class FlatFileNoteDataValidator extends NoteDataValidator
{
    
    ////////////////////
    // NoteDataValidator implementation
    public boolean isValidId (String id)
    {
        // Not accepting null or empty
        if (id == null || id.isEmpty ())
            return false;
        
        // Validate
        Pattern pattern = Pattern.compile ("^[/\\\\:*?\"<>|]{1,30}");
        Matcher matcher = pattern.matcher (id);
        
        return matcher.matches ();
    }
    
    public boolean isValidTag (String tag)
    {
        // Not accepting null or empty
        if (tag == null || tag.isEmpty ())
            return false;
        
        // Validate
        Pattern pattern = Pattern.compile (".{1,30}");
        Matcher matcher = pattern.matcher (tag);
        
        return matcher.matches ();
    }
    
}
